﻿@using System.Diagnostics
@using Library
@using Library.Models
@model IOrderedEnumerable<SpecificationGroup>

@{
    var modelCulture = ViewBag.ModelCulture as ProductCategoryCulture;
    Debug.Assert(modelCulture != null, "modelCulture != null");

    ViewBag.Title = string.Format("{0} \"{1}\"", NOWCulture.GetString("Specifications"), ViewBag.ProductCategoryName);
    Layout = "_Layout.cshtml";
}

<h2>@ViewBag.Title</h2>
<button type="button" class="btn btn-success" data-editor="create" data-id="-1"><span class="glyphicon glyphicon-plus"></span>@NOWCulture.GetString("Create a new specification group")</button>
<div class="clearfix"></div>
<div class="table-responsive">
    <table class="table table-hover" id="specification-groups" data-refid="@ViewBag.RefId">
        <thead>
        <tr>
            <th>@NOWCulture.GetString("Name")</th>
            <th>@NOWCulture.GetString("Description")</th>
            <th>&nbsp;</th>
        </tr>
        </thead>
        <tbody id="tbody">
        @foreach (var specificationGroup in Model)
        {
            @Html.Partial("_SpecificationGroupRow", specificationGroup)
        }
        </tbody>
    </table>
</div>
<div class="pull-left">
    <a class="btn btn-warning" href="@Url.Action("ProductCategories")" title="@NOWCulture.GetString("Go back")"><span class="glyphicon glyphicon-arrow-left"></span> @NOWCulture.GetString("Go back")</a>
</div>
<div class="clearfix"></div>
<div class="modal fade" id="editorModal" tabindex="-1" role="dialog" aria-labelledby="modalLabel" aria-hidden="true">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="@NOWCulture.GetString("Close")"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title pull-left" id="modalLabel">@NOWCulture.GetString("Create new")/@NOWCulture.GetString("Edit") @NOWCulture.GetString("specification group")</h4>
                <div class="pull-right langarea">
                    @foreach (var dic in NOWCulture.Dictionary)
                    {
                        var langName = NOWCulture.GetString(dic.Key.Name);
                        <button type="button" class="btn btn-default btn-xs" data-culture="@dic.Key.Id"><img src="~/Content/cultures/@dic.Key.Id/icon.png" alt="@langName" width="16" height="16" /> @langName</button>
                    }
                </div>
                <div class="clearfix"></div>
            </div>
            <div class="modalloading" id="editorModalLoading">
                <span class="glyphicon glyphicon-refresh glyphicon-refresh-animate"></span> @NOWCulture.GetString("Loading...")
            </div>
            <div id="formctnr"></div>
        </div>
    </div>
</div>
@Html.Action("ConfirmDialog", "Shared", new
{
    title = "",
    content = "",
    alertTitle = NOWCulture.GetString("Oh snap! You got an error!")
})
@section scripts
{
    <script>
        document.currentCulture = '@NOWCulture.CurrentCulture';
        document.twoLetterISOLanguageName = '@NOWCulture.CurrentCultureInfo.TwoLetterISOLanguageName';
        document.modalLabel1 = '@Html.Raw(NOWCulture.GetString("Create new") + "/" + NOWCulture.GetString("Edit") + " " + NOWCulture.GetString("specification group"))';
        document.modalLabel2 = '@Html.Raw(NOWCulture.GetString("Create new") + "/" + NOWCulture.GetString("Edit") + " " + NOWCulture.GetString("specification"))';
        document.modalLabel3 = '@Html.Raw(NOWCulture.GetString("Specification values"))';
        document.confirmLabel1 = '@Html.Raw(NOWCulture.GetString("Remove") + " " + NOWCulture.GetString("specification group"))';
        document.confirmLabel2 = '@Html.Raw(NOWCulture.GetString("Remove") + " " + NOWCulture.GetString("specification"))';
        document.confirmContent1 = '@Html.Raw(string.Format(NOWCulture.GetString("Are you sure you want to remove this {0}?"), NOWCulture.GetString("specification group")))';
        document.confirmContent2 = '@Html.Raw(string.Format(NOWCulture.GetString("Are you sure you want to remove this {0}?"), NOWCulture.GetString("specification")))';
    </script>
    @(HttpContext.Current.IsDebuggingEnabled ? Scripts.Render("~/bundles/admin-specifications") : Scripts.RenderFormat(@"<script src=""{0}"" async defer></script>", "~/bundles/admin-specifications"))
}